# coding=utf-8
import datetime, time, logging.handlers
import sys
import string
sys.path.append("..")
from config.config import *
from libraries import dbase

# 初始化数据库连接
ccms = dbase.initializeDb(CCMSDB)


def write_diamond_data(sql):
    db = dbase.getOneConn(ccms)
    logger.info(u"群呼任务报表:%s" % sql)
    db.execute(sql)
    db.commit()
    db.close()

# 获取有效任务号码 取消的方法
def query_get_data(sql):
    db = dbase.getOneConn(ccms)
    result = db.query(sql)
    return result
    db.close()


# 更新号码状态,通话中，取消的方法
def up_diamond_data(sql, param):
    db = dbase.getOneConn(ccms)
    try:  
        # 批量插入  
        db.executemany(sql, param)  
        db.commit()  
        db.close()
    except Exception as e:  
        print e  


def add_diamond_data(sql):
    db = dbase.getOneConn(ccms)
    db.execut(sql)  
    db.commit()  
    db.close()
  